import { OtherKey, EventKey } from "../common/Key";
import { GameData } from "../game/GameData";
cc.Class({
    extends: require('BasePanel'),

    properties: {
        nodFinger: cc.Node,
    },
    onLoad() {
        this._super();
        this.nodMask.active = false;
    },

    onEnter(args, action = true) {
        this._super(args, action);
        this._composeCount = 0;
    },

    onExit(args) {
        this._super(args);
        GameData.setGuided();
    },

    show() {

    },

    hide(cb) {
        cb && cb();
    },
    onEnable() {
        this._registEvent();
    },
    onDisable() {
        this._unRegistEvent();
    },

    _onFire(eventName, param) {
        if (eventName == EventKey.EVENT_TRY_COMPOSE_ANIMAL) {
            this.nodFinger.active = false;
            this._composeCount++;
            if (this._composeCount >= 2) {
                this.onClose();
            }
        }
    },

    _registEvent() {
        G.onFire.on(EventKey.EVENT_TRY_COMPOSE_ANIMAL, this._onFire, this);
    },
    _unRegistEvent() {
        G.onFire.off(EventKey.EVENT_TRY_COMPOSE_ANIMAL, this._onFire, this);
    },


    buttonListener: function (button) {
        let name = button.node.name;
        if (name == 'btnClose') {
            this.onClose();
        }
    },

    onTouchStart() {

    },
});
